package com.hydl.power.controller;

import com.github.pagehelper.PageInfo;
import com.hydl.power.aop.annotation.LogAnnotation;
import com.hydl.power.mapper.GatewayMapper;
import com.hydl.power.pojo.Device;
import com.hydl.power.service.*;
import com.hydl.power.utils.Resp;
import io.micrometer.core.instrument.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "DeviceController", tags = "模糊查询")
@RestController
@RequestMapping("/fuzzyZearch")
@CrossOrigin
public class FuzzySearchController {

    @Autowired
    private DeviceService deviceService;
    @Autowired
    private ProjectService projectService;
    @Autowired
    private PowerRoomService powerRoomService;
    @Autowired
    private GatewayService gatewayService;
    @Autowired
    private TransformerService transformerService;

    // @LogAnnotation(module = "项目模糊查询",description = "项目模糊查询")
    @ApiOperation("项目模糊查询")
    @PostMapping("/queryProjectLike")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNum", value = "页数",required = false,  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "条数",required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "text", value = "搜索内容",  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "token", value = "token",  dataType = "String")
    })
    public Resp queryProjectLike( Integer pageNum,Integer pageSize,String text,String token) {
        return Resp.success(projectService.queryProjectLike(pageNum,pageSize,text,token));
    }

    // @LogAnnotation(module = "配电房模糊查询",description = "配电房模糊查询")
    @ApiOperation("配电房模糊查询")
    @PostMapping("/queryPowerRoomLike")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNum", value = "页数",required = false,  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "条数",required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "text", value = "搜索内容",  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "token", value = "token",  dataType = "String")
    })
    public Resp queryPowerRoomLike( Integer pageNum,Integer pageSize,String text,String token) {
        return Resp.success(powerRoomService.queryPowerRoomLike(pageNum,pageSize,text,token));
    }

    // @LogAnnotation(module = "网关模糊查询",description = "网关模糊查询")
    @ApiOperation("网关模糊查询")
    @PostMapping("/queryGatewayLike")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNum", value = "页数",required = false,  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "条数",required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "text", value = "搜索内容",  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "token", value = "token",  dataType = "String")
    })
    public Resp queryGatewayLike( Integer pageNum,Integer pageSize,String text,String token) {
        return Resp.success(gatewayService.queryGatewayLike(pageNum,pageSize,text,token));
    }

    // @LogAnnotation(module = "设备模糊查询",description = "设备模糊查询")
    @ApiOperation("设备模糊查询")
    @PostMapping("/queryDeviceLike")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNum", value = "页数",required = false,  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "条数",required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "text", value = "搜索内容",  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "token", value = "token",  dataType = "String")
    })
    public Resp queryDeviceLike(Integer pageNum,Integer pageSize, String text,String token) {
        return Resp.success(deviceService.queryDeviceLike(pageNum,pageSize,text,token));
    }

    //@LogAnnotation(module = "变压器模糊查询",description = "变压器模糊查询")
    @ApiOperation("变压器模糊查询")
    @PostMapping("/queryTransformerLike")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNum", value = "页数",required = false,  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "条数",required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "text", value = "搜索内容",  dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "token", value = "token",  dataType = "String")
    })
    public Resp queryTransformerLike( Integer pageNum,Integer pageSize,String text,String token) {
        return Resp.success(transformerService.queryTransformerLike(pageNum,pageSize,text,token));
    }
}
